package com.ruoyi.shopping.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.shopping.mapper.BbsCommentsMapper;
import com.ruoyi.shopping.domain.BbsComments;
import com.ruoyi.shopping.service.IBbsCommentsService;

/**
 * 论坛评论Service业务层处理
 *
 * @author ruoyi
 * @date 2022-06-20
 */
@Service
public class BbsCommentsServiceImpl implements IBbsCommentsService
{
    @Autowired
    private BbsCommentsMapper bbsCommentsMapper;

    /**
     * 查询论坛评论
     *
     * @param id 论坛评论主键
     * @return 论坛评论
     */
    @Override
    public BbsComments selectBbsCommentsById(Long id)
    {
        return bbsCommentsMapper.selectBbsCommentsById(id);
    }

    /**
     * 查询论坛评论列表
     *
     * @param bbsComments 论坛评论
     * @return 论坛评论
     */
    @Override
    public List<BbsComments> selectBbsCommentsList(BbsComments bbsComments)
    {
        return bbsCommentsMapper.selectBbsCommentsList(bbsComments);
    }

    /**
     * 新增论坛评论
     *
     * @param bbsComments 论坛评论
     * @return 结果
     */
    @Override
    public int insertBbsComments(BbsComments bbsComments)
    {
        bbsComments.setCreateTime(DateUtils.getNowDate());
        return bbsCommentsMapper.insertBbsComments(bbsComments);
    }

    /**
     * 修改论坛评论
     *
     * @param bbsComments 论坛评论
     * @return 结果
     */
    @Override
    public int updateBbsComments(BbsComments bbsComments)
    {
        bbsComments.setUpdateTime(DateUtils.getNowDate());
        return bbsCommentsMapper.updateBbsComments(bbsComments);
    }

    /**
     * 批量删除论坛评论
     *
     * @param ids 需要删除的论坛评论主键
     * @return 结果
     */
    @Override
    public int deleteBbsCommentsByIds(Long[] ids)
    {
        return bbsCommentsMapper.deleteBbsCommentsByIds(ids);
    }


    /**
     * 批量逻辑删除论坛评论
     *
     * @param ids 需要删除的论坛评论主键
     * @return 结果
     */
    @Override
    public int logicDeleteBbsComments(Long[] ids,String delType,Long delUser)
    {
        return bbsCommentsMapper.logicDeleteBbsComments(ids,delType,delUser);
    }

    /**
     * 删除论坛评论信息
     *
     * @param id 论坛评论主键
     * @return 结果
     */
    @Override
    public int deleteBbsCommentsById(Long id)
    {
        return bbsCommentsMapper.deleteBbsCommentsById(id);
    }

    @Override
    public Integer selectCountByBBsId(Long bbsId) {
        return bbsCommentsMapper.selectCountByBBsId(bbsId);
    }

    @Override
    public List<BbsComments> findComment(Long bbsId, Long parentId, SqlSession factory) {
//        BbsCommentsMapper mapper = factory.getMapper(BbsCommentsMapper.class);
//        return mapper.findComment(bbsId,parentId);
        return bbsCommentsMapper.findComment(bbsId,parentId);
    }

    @Override
    public List<BbsComments> selectListByBBsId(Long bbsId) {
        return bbsCommentsMapper.selectListByBBsId(bbsId);
    }

    @Override
    public List<BbsComments> selectListByParentId(Long id) {
        return bbsCommentsMapper.selectListByParentId(id);
    }

    @Override
    public List<BbsComments> loadMore(Long id, Long bbsId,Long parentId, int limit) {
        return bbsCommentsMapper.loadMore(id,bbsId,parentId,limit);
    }
}
